﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TuringMachine.Classes;

namespace TuringMachine.UnitTests
{
    [TestClass]
    public class TapeTests
    {
        [TestMethod]
        public void InitializeTape_PositionIsZeroAndLengthIsOneAndValueIsNull()
        {
            //arrange
            var tape = new Tape();

            //assert
            Assert.AreEqual(0, tape.Position, "Position != 0");
            Assert.AreEqual(1, tape.Length, "Tape length != 1");
            Assert.AreEqual(null, tape.ReadCell(), "Cell value is != null");
        }

        [TestMethod]
        public void MoveCell_TapeIsInitializedAndMovedLeft_PositionIsZeroAndLengthIsTwoAndValueIsNull()
        {    
            //arrange
            var tape = new Tape();

            //act
            tape.MoveCell(MoveDirection.Left);

            //assert
            Assert.AreEqual(0, tape.Position, "Position != 0");
            Assert.AreEqual(2, tape.Length, "Tape length != 2");
            Assert.AreEqual(null, tape.ReadCell(), "Cell value is != null");
        }

        [TestMethod]
        public void MoveCell_TapeIsInitializedAndMovedRight_PositionIsOneAndLengthIsTwoAndValueIsNull()
        {
            //arrange
            var tape = new Tape();

            //act
            tape.MoveCell(MoveDirection.Right);

            //assert
            Assert.AreEqual(1, tape.Position, "Position != 1");
            Assert.AreEqual(2, tape.Length, "Tape length != 2");
            Assert.AreEqual(null, tape.ReadCell(), "Cell value is != null");
        }

        [TestMethod]
        public void WriteCell_TapeIsInitializedAndCellIsWrittenWithOne_PositionIsOneAndLengthIsOneAndValueIsOne()
        {
            //arrange
            var tape = new Tape();

            //act
            tape.WriteCell(1);

            //assert
            Assert.AreEqual(0, tape.Position, "Position != 0");
            Assert.AreEqual(1, tape.Length, "Tape length != 1");
            Assert.AreEqual(1, tape.ReadCell(), "Cell value is != 1");
        }
    }
}
